﻿//===========================[ 7 / 6 / 2011 LVI ]==========================
//           Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
//                             Source file
// Purpose: Entry point application Prototype Game Demo
//=========================================================================
#include "cPGDemo.h"

Kernel  *pKernel  = nullptr;
cPGDemo *pDemoApp = nullptr;

int APIENTRY WinMain( HINSTANCE,HINSTANCE,LPTSTR,int )
{
	int result = 0;

	pKernel = new Kernel;
	pKernel = &Kernel::spec();

	pDemoApp = new cPGDemo;

	// if fail to create any systems
	if ( !pKernel->Create() )
	{
		cwLogger::writeERROR("ERROR Create kernel! Shutdown Application");

		pKernel->Destroy();

		if ( pDemoApp )
			SAFE_DELETE( pDemoApp );

		DebugMessage("ERROR Create Kernel! See the log file.");
		return -1;
	}
	
	result = pKernel->ExecLoop();

	pKernel->Destroy();

	if ( pDemoApp )
		SAFE_DELETE( pDemoApp );

	return result;
}